<template>
  <div class="icons">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(item,index) of page" :key="index">
        <div class="icons-item" v-for="icons in item" :key="icons.id">
          <img :src="icons.imgUrl" :alt="icons.title">
          <p class="title">{{ icons.title }}</p>
        </div>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
export default {
  data () {
    return {
      iconsList: [
        {
          'id': '01',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '景点门票'
        },
        {
          'id': '77',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '一日行'
        },
        {
          'id': '02',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '热门演出'
        },
        {
          'id': '31',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '泡温泉'
        },
        {
          'id': '002',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '一日游'
        },
        {
          'id': '55',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '动植物园'
        },
        {
          'id': '78',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '华清宫'
        },
        {
          'id': '012',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '兵马俑'
        },
        {
          'id': '44',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '一日行'
        },
        {
          'id': '10',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '华山'
        },
        {
          'id': '11',
          imgUrl: 'http://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20194/437aad2dd0c1edb38fee0c51f8f9dd02.png',
          title: '秋趣河南'
        }
      ],
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        },
        loop: true
      }
    }
  },
  computed: {
    page () {
      let pages = []
      this.iconsList.forEach((item, index) => {
        // console.log(index);
        let idx = Math.floor(index / 8)
        if (!pages[idx]) pages[idx] = []
        pages[idx].push(item)
      })
      // console.log(pages)
      return pages
    }
  }
}
</script>

<style scoped>
  .icons {
    width: 100%;
    overflow: hidden;
    padding-bottom: .4rem;
    background-color: #fff;
  }
  .icons-item {
    width: 25%;
    padding-top: .2rem;
    float: left;
  }
  .icons-item img {
    width: 1.1rem;
    height: 1.1rem;
    display: block;
    margin: 0 auto;
  }
  .icons-item .title {
    font-size: .28rem;
    text-align: center;
    margin-top: .1rem;
  }
  .icons >>> .swiper-pagination-bullet-active {
    background: rgba(0,175,190,.8);
  }
  .icons >>> .swiper-pagination-bullet {
    width: 6px;
    height: 6px;
  }
  .swiper-pagination {
    top: 137px;
  }
  .swiper-container {
     overflow: unset;
  }
</style>
